package cn.tedu.csmall.stock.webapi.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail showTime(){
        return JobBuilder.newJob(QuartzJob.class)
                .withIdentity("dataTime")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showTimeTrigger(){
        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0/10 * * 7 2 ?");
        return TriggerBuilder.newTrigger()
                .forJob(showTime())
                .withIdentity("dateTimeTrigger")
                .withSchedule(cron)
                .build();
    }
}
